/**
 * @type {Number}
 *
 * @properties={typeid:35,uuid:"E7B30124-0D1D-425D-ABD2-0CB226F97DD3",variableType:4}
 */
var $historico = 0;

/**
 * @type {Number}
 *
 * @properties={typeid:35,uuid:"CA5EB817-E9B3-434A-8CB6-62C918891271",variableType:4}
 */
var $historico_listado_perfiles = 1;

/**
 * @type {Number}
 *
 * @properties={typeid:35,uuid:"D8D8A3F7-DAB8-4B75-8C48-E49B2E6C20A2",variableType:4}
 */
var $historico_listado_usuarios = 2;

/**
 * @type {Number}
 *
 * @properties={typeid:35,uuid:"EEA5BF41-DDBD-4005-BC4E-F102263104BF",variableType:4}
 */
var $historico_listado_apli_emp = 3;

/**
 * @properties={typeid:24,uuid:"9786BD5B-58F1-4A4F-8679-CB567274CF83"}
 */
function doEdit(){
	
	elements.historicos.enabled = false;
	elements.btn_alta_historicos.enabled = false;
	elements.btn_menu_historicos.enabled = false;
	elements.tab_historicos.enabled = false;
	controller.focusField(elements.fld_s_descripcion.getName(),true);
}

/**
 * @properties={typeid:24,uuid:"D9B96189-E1FC-4022-A6B5-F43470A0216C"}
 */
function hide_btn_reset_fields(){
	
	elements.historicos.enabled = true;
	elements.btn_alta_historicos.enabled = true;
	elements.btn_menu_historicos.enabled = true;
	elements.tab_historicos.enabled = true;
}

/**
 * Opciones propias del menú
 * @author Roberto J. Blasco
 * @version 1.0
 * @param event
 *
 * @properties={typeid:24,uuid:"32FF69B8-0A23-4592-BEE7-309B239F95B7"}
 */
function opciones(event){
	
	var submenu_alta_perfil = $menu.addMenuItem("Alta Perfil", alta_perfil);
	submenu_alta_perfil.methodArguments = [event, foundset.getSelectedRecord()];
	var submenu_alta_usuario = $menu.addMenuItem("Alta Usuario", alta_usuario);
	submenu_alta_usuario.methodArguments = [event, foundset.getSelectedRecord()];
}

/**
 * Alta de un nuevo Perfil
 * @author Roberto J. Blasco
 * @version 1.0
 * @private 
 * @properties={typeid:24,uuid:"EA4A7D18-C2B0-4321-80DC-84DF385E1D01"}
 */
function alta_perfil(){
	
	
}

/**
 * Alta de un nuevo Usuario
 * @author Roberto J. Blasco
 *  @version 1.0
 *  @private 
 * @properties={typeid:24,uuid:"F829C7A3-3038-4748-8973-2D8E8EFC2344"}
 */
function alta_usuario(){
	
	
}

/**
 * Handle changed data.
 *
 * @param {Number} oldValue old value
 * @param {Number} newValue new value
 * @param {JSEvent} event the event that triggered the action
 *
 * @returns {Boolean}
 *
 * @private
 *
 * @properties={typeid:24,uuid:"D3AC2EE4-2454-4915-AC39-B38770A8CFF3"}
 */
function onDataChangeHistorico(oldValue, newValue, event) {

	elements.tab_historicos.removeAllTabs();
	if ($historico == $historico_listado_perfiles){
		elements.tab_historicos.addTab(forms.lst_adm_t900_perfiles_h,null,null,null,null,null,null, adm_t900_aplicaciones_id);
	}else if  ($historico == $historico_listado_usuarios){
		elements.tab_historicos.addTab(forms.lst_adm_t900_usuarios_h,null,null,null,null,null,null, adm_t900_empresas_to_adm_t900_usuarios);
	}else if ($historico == $historico_listado_apli_emp){
		elements.tab_historicos.addTab(forms.lst_adm_t300_apli_emp__emp_h,null,null,null,null,null,null, adm_t900_aplicaciones_to_adm_t300_apli_emp);
	}
	return true
}

/**
 * Callback method for when form is shown.
 * @author Roberto J. Blasco
 * @version 1.0
 * @param {Boolean} firstShow form is shown first time after load
 * @param {JSEvent} event the event that triggered the action
 * @private
 * @properties={typeid:24,uuid:"E6505212-4F65-46E0-8C6E-106429ACB88E"}
 */
function onShow(firstShow, event) {

	if (foundset.getSelectedRecord().isNew()){
		elements.tab_historicos.visible = false;
	}else{
		
		var dataset = databaseManager.createEmptyDataSet(0,new Array('display_values','optional_real_values'));
		dataset.addRow(['LISTADO DE EMPRESAS', $historico_listado_apli_emp]);
		dataset.addRow(['LISTADO DE PERFILES', $historico_listado_perfiles]);
		dataset.addRow(['LISTADO DE USUARIOS', $historico_listado_usuarios]);
		elements.historicos.setValueListItems(dataset);
		
		elements.tab_historicos.visible = true;
		elements.tab_historicos.removeAllTabs();
		$historico = $historico_listado_apli_emp;
		elements.tab_historicos.addTab(forms.lst_adm_t300_apli_emp__emp_h,null,null,null,null,null,null,adm_t900_aplicaciones_to_adm_t300_apli_emp);
	}
}

/**
 * @param {JSEvent} event
 * @properties={typeid:24,uuid:"7643D603-3758-4B5B-ADE1-43C672DCCCD0"}
 */
function eliminar_antes(event){

}

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"02F7C9AF-C110-43BC-84EA-2BC033908099"}
 */
function historico_opciones(event) {

}

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"1CC0AE62-45C2-48DA-A325-57AB1E44FAB9"}
 */
function historico_alta(event) {

	/** @type {JSDataSet} */
	var ds = databaseManager.createEmptyDataSet();
	ds.addRow(['adm_t900_aplicaciones_id', adm_t900_aplicaciones_id]);
	
	if ($historico == $historico_listado_perfiles){
		globals.ir_formulario(event,forms.frm_adm_t900_perfiles.controller.getName(),null,globals.$MODO_ALTA,ds);
	}else if ($historico == $historico_listado_usuarios){
		globals.ir_formulario(event, forms.frm_adm_t900_usuarios.controller.getName(), null,  globals.$MODO_ALTA,ds);
	}else if ($historico == $historico_listado_apli_emp){
		globals.ir_formulario(event,forms.frm_adm_t900_apli_emp.controller.getName(),null,globals.$MODO_ALTA, ds);
	}
}
